home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11224 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.2 KB

  1. Path: ix.netcom.com!news
  2. From: miker3@ix.netcom.com (Mike Rubenstein)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: fflush and Visual C++
  5. Date: Fri, 22 Mar 1996 17:21:24 GMT
  6. Organization: Netcom
  7. Message-ID: <3152d29a.183262006@nntp.ix.netcom.com>
  8. References: <4idhv5$dnv@news.mhv.net> <314b173b.71056173@nntp.ix.netcom.com> <4ifuuf$fha@solutions.solon.com> <4issod$jkf@newshost.cyberramp.net>
  9. NNTP-Posting-Host: ix-dc6-04.ix.netcom.com
  10. X-NETCOM-Date: Fri Mar 22 11:20:50 AM CST 1996
  11. X-Newsreader: Forte Agent .99d/32.182
  12.  
  13. sinan@cyberramp.net (John Noland) wrote:
  14.  
  15. > In article <4ifuuf$fha@solutions.solon.com>, seebs@solutions.solon.com says...
  16. > >
  17. > >In article <314b173b.71056173@nntp.ix.netcom.com>,
  18. > >Mike Rubenstein <miker3@ix.netcom.com> wrote:
  19. > >>Perhaps because Visual C implements fflush() correctly.  fflush() does
  20. > >>not flush input buffers.  fflush() with stdin as an argument results
  21. > >>in undefined behavior.
  22. > >
  23. > >The first part of this is incorrect.  fflush() may flush input buffers.
  24. > >It may cause the program to abort.  It may do nothing.  But there's
  25. > >nothing *wrong* with it choosing to discard pending input when invoked
  26. > >on an input stream.  Except that it's rude of an implementation to offer
  27. > >a silent extension, it causes people to make mistakes.
  28. > Sorry to keep getting myself in trouble, but...
  29. > With Micrsoft's Visual C compiler, if the stream is open for input, fflush()
  30. > clears the contents of the buffer. I don't have any thoughts on the ANSIness
  31. > of this behavior, but that's the way the manual says it works. It also says
  32. > the fflush() function negates the effect of any prior call to ungetc() against
  33. > the stream. And then it has the mark saying this function is ANSI compliant.
  34. > I gather PS's remarks about rudeness are correct?
  35.  
  36. Whoops.  You are correct.  The documentation does say that and looking
  37. at the source I now see how this works.  The comments in the source do
  38. not reflect this and I missed the code that does clear the buffer on
  39. input streams.
  40.  
  41. Since ANSI says that calling fflush() with an input stream results in
  42. undefined behavior (as I and Pete have pointed out), the compler could
  43. do anything in this case and be ANSI compliant.
  44.  
  45.  
  46. Michael M Rubenstein
  47.